package com.mutouren.modules.datapush.netty;

import io.netty.channel.ChannelInitializer;
import io.netty.channel.socket.SocketChannel;
import io.netty.handler.codec.http.HttpObjectAggregator;
import io.netty.handler.codec.http.HttpRequestDecoder;
import io.netty.handler.codec.http.HttpResponseEncoder;

public class HttpServerInitializer  extends ChannelInitializer<SocketChannel> {

	@Override
	protected void initChannel(SocketChannel ch) throws Exception {
		
		ch.pipeline().addLast("http-decoder", new HttpRequestDecoder());  
		// 聚合器，把多个消息转换为一个单一的FullHttpRequest或是FullHttpResponse  
		ch.pipeline().addLast("http-aggregator", new HttpObjectAggregator(65536));  
		ch.pipeline().addLast("http-encoder", new HttpResponseEncoder());
		
		//ch.pipeline().addLast("http-chunked", new ChunkedWriteHandler());  
		//ch.pipeline().addLast("deflater", new HttpContentCompressor());
		
		ch.pipeline().addLast("mtr-inboundHandler", new HttpServerInboundHandler2()); 
		
	}

}
